package com.atguigu.lease.common.exception;

import com.atguigu.lease.common.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author：yyj
 * @Package：com.atguigu.lease.common.exception
 * @Project：project01
 * @name：GlobalExceptionHandler
 * @Date：2024/11/18 19:35
 * @Filename：GlobalExceptionHandler
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(UserExist.class)
    public Result handleException(UserExist e){
        e.printStackTrace();
        return Result.build(e.getCode(),e.getMessage());
    }

    @ExceptionHandler(LeaseException.class)
    public Result error(LeaseException e) {
        e.printStackTrace();
        return Result.build(e.getCode(),e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public Result error(Exception e) {
        e.printStackTrace();
        return Result.fail();
    }
}
